package responsitory;


import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import bean.LunBoBean;
import bean.ShouYeBean;
import util.volley.BaseErrorListener;
import util.volley.BaseNetRepository;
import util.volley.BaseSuccessReqListener;
import util.volley.ByJsonRequest;
import util.volley.ICompleteListener;

/**
 * 轮播
 */

public class LunBoResponsitory extends BaseNetRepository {

    final String api = "101";
    //轮播
    final String LunBoQuery = "By_Banners_query";
    //轮播统计
    final String LunBoTongJi = "By_Banners_click";
    //首页数据
    final String shouye = "By_Index_index";
    public LunBoResponsitory(ICompleteListener iCompleteListener) {
        super(iCompleteListener);
    }

    public void lunBo(String position) {
        Type type = new TypeToken<List<LunBoBean>>() {
        }.getType();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("position", position);
        (new ByJsonRequest.Builder<List<LunBoBean>>())
                .setTypeVerParamsAndReturnClass(LunBoQuery, api, map, type)
                .requestListener(
                        new BaseSuccessReqListener<List<LunBoBean>>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
    public void lunBoTongJi(String id) {
        Type type = new TypeToken<String>() {
        }.getType();
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        (new ByJsonRequest.Builder<String>())
                .setTypeVerParamsAndReturnClass(LunBoTongJi, "100", map, type)
                .requestListener(
                        new BaseSuccessReqListener<String>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
    public void shouye(String uid,String size) {
        Type type = new TypeToken<ShouYeBean>() {
        }.getType();
        String Api=api;
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("uid", uid);
        map.put("size", size);
        (new ByJsonRequest.Builder<ShouYeBean>())
                .setTypeVerParamsAndReturnClass(shouye, Api, map, type)
                .requestListener(
                        new BaseSuccessReqListener<ShouYeBean>(
                                getListener()))
                .errorListener(new BaseErrorListener(getListener()))
                .desEncodeThenBuildAndSend();
    }
}
